import { Map } from 'immutable'
import * as actionTypes from './constants'
const defaultState = Map({
  songList: [
    {
      "name": "浪漫主义",
    "id": 1887917182,
    "pst": 0,
    "t": 0,
    "ar": [
    {
    "id": 1198123,
    "name": "姜云升",
    "tns": [],
    "alias": []
    }
    ],
    "alia": [],
    "pop": 100,
    "st": 0,
    "rt": "",
    "fee": 8,
    "v": 4,
    "crbt": null,
    "cf": "",
    "al": {
    "id": 134922893,
    "name": "浪漫主义",
    "picUrl": "https://p1.music.126.net/lFFiY-jvO1ENHtK2bZ6eUw==/109951166531420475.jpg",
    "tns": [],
    "pic_str": "109951166531420475",
    "pic": 109951166531420480
    },
    "dt": 216746,
    "h": {
    "br": 320000,
    "fid": 0,
    "size": 8672685,
    "vd": -47907
    },
    "m": {
    "br": 192000,
    "fid": 0,
    "size": 5203629,
    "vd": -45299
    },
    "l": {
    "br": 128000,
    "fid": 0,
    "size": 3469101,
    "vd": -43623
    },
    "a": null,
    "cd": "01",
    "no": 1,
    "rtUrl": null,
    "ftype": 0,
    "rtUrls": [],
    "djId": 0,
    "copyright": 0,
    "s_id": 0,
    "mark": 8192,
    "originCoverType": 1,
    "originSongSimpleData": null,
    "tagPicList": null,
    "resourceState": true,
    "version": 4,
    "songJumpInfo": null,
    "single": 0,
    "noCopyrightRcmd": null,
    "mst": 9,
    "cp": 0,
    "rtype": 0,
    "rurl": null,
    "mv": 0,
    "publishTime": 0
    }
  ],
  currentSongDetail: {
    "name": "浪漫主义",
  "id": 1887917182,
  "pst": 0,
  "t": 0,
  "ar": [
  {
  "id": 1198123,
  "name": "姜云升",
  "tns": [],
  "alias": []
  }
  ],
  "alia": [],
  "pop": 100,
  "st": 0,
  "rt": "",
  "fee": 8,
  "v": 4,
  "crbt": null,
  "cf": "",
  "al": {
  "id": 134922893,
  "name": "浪漫主义",
  "picUrl": "https://p1.music.126.net/lFFiY-jvO1ENHtK2bZ6eUw==/109951166531420475.jpg",
  "tns": [],
  "pic_str": "109951166531420475",
  "pic": 109951166531420480
  },
  "dt": 216746,
  "h": {
  "br": 320000,
  "fid": 0,
  "size": 8672685,
  "vd": -47907
  },
  "m": {
  "br": 192000,
  "fid": 0,
  "size": 5203629,
  "vd": -45299
  },
  "l": {
  "br": 128000,
  "fid": 0,
  "size": 3469101,
  "vd": -43623
  },
  "a": null,
  "cd": "01",
  "no": 1,
  "rtUrl": null,
  "ftype": 0,
  "rtUrls": [],
  "djId": 0,
  "copyright": 0,
  "s_id": 0,
  "mark": 8192,
  "originCoverType": 1,
  "originSongSimpleData": null,
  "tagPicList": null,
  "resourceState": true,
  "version": 4,
  "songJumpInfo": null,
  "single": 0,
  "noCopyrightRcmd": null,
  "mst": 9,
  "cp": 0,
  "rtype": 0,
  "rurl": null,
  "mv": 0,
  "publishTime": 0
  },
  currentSongIndex: 0,
  songLyric: [],
  currentSongLyricIndex: 0,
  howPlay:0 //0列表 1单曲 2 随机
})

export default function reducer(state = defaultState, action) {
  switch (action.type) {
    case actionTypes.CHANGE_CURRENT_SONG_DETAIL:
      return state.set('currentSongDetail', action.currentSongDetail)
    case actionTypes.CHANGE_CURRENT_INDEX:
      return state.set('currentSongIndex', action.currentSongIndex)
    case actionTypes.CHANGE_SONG_LIST:
      return state.set('songList', action.songList)
    case actionTypes.CHANGE_SONG_LYRIC:
      return state.set('songLyric', action.songLyric)
    case actionTypes.CAHENG_CURRENT_SONG_LYRIC_INDEX:
      return state.set('currentSongLyricIndex', action.currentSongLyricIndex)
    case actionTypes.CHANGE_HOW_PLAY_ACTION:
      return state.set('howPlay',action.howPlay)
    default:
      return state
  }
}

